package com.example.mq.listener;

import com.example.commonutils.constants.MqConstants;
import com.example.mq.service.MqService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class LearnListener {
    @Autowired
    private MqService mqService;
    //监听新增或修改课程
    @RabbitListener(queues = MqConstants.LEARN_INSERT_QUEUE)
    public void listenLearnInsertOrUpdate(String id){
        mqService.insertById(id);
    }
    //监听删除课程
    @RabbitListener(queues = MqConstants.LEARN_DELETE_QUEUE)
    public void listenLearnDelete(String id){
        mqService.deleteById(id);
    }

    //监听新增或修改文章
    @RabbitListener(queues = MqConstants.ARTICLE_INSERT_QUEUE)
    public void listenArticleInsertOrUpdate(String id){
        mqService.insertArticleById(id);
    }
    //监听删除文章
    @RabbitListener(queues = MqConstants.ARTICLE_DELETE_QUEUE)
    public void listenArticleDelete(String id){
        mqService.deleteArticleById(id);
    }
}
